package com.somta.springboot.controller;

import com.alibaba.fastjson.JSONObject;
import com.somta.springboot.pojo.User;
import com.somta.springboot.repository.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.xml.ws.Action;

@RestController
public class UserController {

	@Autowired
	private UserRepository userRepository;

	@RequestMapping("/")
	public String helloWorld() {
		return "hello World";
	}
	/**
	 * 测试地址  http://localhost:8080/getUser?name=zhao
	 * @param name
	 * @return
	 */
	@RequestMapping("/getUser")
	@ResponseBody
	public String user(String name) {
		User user = userRepository.findUser(name);
		return JSONObject.toJSONString(user);
	}

}
